package com.ucode.hrm.service;

import cn.hutool.core.util.ObjectUtil;
import com.ucode.hrm.mapper.HrmPaySlipMapper;
import com.ucode.model.hrm.HrmPaySlip;
import com.ucode.springboot.starter.mybatis.core.base.BaseService;
import com.ucode.tool.base.enums.GlobalResultCodeEnum;
import com.ucode.tool.exception.UcodeServiceException;

import java.util.Collection;
import java.util.List;

/**
 * 工资条 Service
 * @Author: liliang
 * @Date: 2025/8/10 12:21
 * @Version: 1.0
 */
public interface HrmPaySlipService extends BaseService<Long,HrmPaySlip, HrmPaySlipMapper> {
    /**
     * 工资条显示字段
     */
    public static final String PAY_SLIP_SHOW_COLUMNS = "hrm:pay-slip:show-columns";

    /**
     * 设置工资条显示字段
     * @param showColumns
     */
    public void setPaySlipShowColumns(List<String> showColumns);

    /**
     * 获取工资条显示字段
     * @return
     */
    public List<String> getPaySlipShowColumns();
    /**
     * 批量添加
     * @param list
     * @return
     */
    public int batchInsert(List<HrmPaySlip> list);

    /**
     * 批量更新可见状态
     * @param ids
     * @param visible
     * @return
     */
    public int updateVisibleByIds(Collection<Long> ids, Boolean visible);

    /**
     * 验证是否合法并返回
     * @param id
     * @return
     */
    default HrmPaySlip validate(Long id){
        if(ObjectUtil.isNull(id) )
            throw new UcodeServiceException(GlobalResultCodeEnum.VALIDATE_FAILED);
        //验证数据是否存在
        HrmPaySlip brand = this.selectByPrimaryKey(id);
        if(ObjectUtil.isNull(brand) || brand.getDeltag()){
            throw new UcodeServiceException(GlobalResultCodeEnum.NO_RECORD.getCode(),"工资条不存在或已删除");
        }
        return brand;
    }
}
